package com.ymatou.iapi.mqcompensate.testcase;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.mqcompensate.parameter.CompensateBean;
import com.ymatou.iapi.mqcompensate.service.CompensateCall;
import com.ymatou.iapi.mqpublish.parameter.PublishBean;
import com.ymatou.iapi.mqpublish.service.PublishCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.MqCompensateCallService;
import com.ymttest.business.service.MqPublishCallService;
import com.ymttest.database.mongo.MQMessageBean;
import com.ymttest.database.mongo.MQMessageCompensateBean;
import com.ymttest.database.mongo.MQMessageCompensateWapper;
import com.ymttest.database.mongo.MQMessageStatusBean;
import com.ymttest.database.mongo.MQMessageStatusWapper;
import com.ymttest.database.mongo.MQMessageWapper;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;
/**
*补发消息用例
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Compensate{
	private static CompensateBean compensateBean;
	private static CompensateCall compensateCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("补发消息用例");
	}

	@Before
	public void caseUp() {
		compensateBean=new CompensateBean();
		compensateCall=new CompensateCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(compensateCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_001() {
		Logger.start(true,"补发消息-接收成功");
		try {
			// 关掉自动补单
			new MqCompensateCallService().StopMqCompensate();
			
			SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMM");
			String dateStr1 = sDateFormat.format(new java.util.Date());

			String appName = "testbamei";
			String codeName = "qusi";

			String uuid = dateStr1 + "." + TestDataManager.getRandomUUID().toString();
			String msguniqueid = TestDataManager.getRandomNum(10);
			String body = TestDataManager.randomStr(20);
			String busIp = "127.0.0.1";

			Date nowTime = new Date();
			Date date = new Date(nowTime.getTime() - 9*60 * 60 * 1000);
			Date date3 = new Date(nowTime.getTime() - 8*60 * 60 * 1000);
			Date date2 = new Date(nowTime.getTime() - 9*60 * 60 * 1000+60*60*1000+60*1000);
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
			String dateStr = format.format(date);

			String json = "{\"uuid\" : \"" + uuid + "\",\"aid\" : \"" + appName + "\",\"code\" : \"" + codeName + "\","
					+ "\"mid\" : \"" + msguniqueid + "\",\"ip\" : \"127.0.0.1\",\"busIp\" : \"" + busIp + "\","
					+ "\"body\" : \"\\\"" + body + "\\\"\",\"ctime\" : {$date:\"" + dateStr + "\"},"
					+ "\"pushstatus\" : 1000,\"nstatus\" : 0,\"pstatus\" : 0," + "\"pushtime\" : {$date:\"" + dateStr
					+ "\"}}";
			Logger.comment(json);

			new MQMessageWapper().saveData(appName, codeName, json);
			
			new MqCompensateCallService().CheckToChompensateCall(appName, codeName);
			
			compensateBean.setAppId(appName);
			compensateBean.setCode(codeName);
			
			List<MQMessageStatusBean> statusList = new MQMessageStatusWapper().getStatusByMid(appName, msguniqueid);
			int num1 = statusList.size();

			Thread.sleep(60000);
			compensateCall.setData(compensateBean);
			compensateCall.callService();			

			Thread.sleep(1000);
			
			// 验证消息成功
			MQMessageBean messageBean = new MQMessageWapper().getMessageByMid(appName,codeName,msguniqueid);

			Logger.verifyEquals(appName, messageBean.getAid(), "验证数据库Aid");
			Logger.verifyEquals(codeName, messageBean.getCode(), "验证数据库Code");
			Logger.verifyEquals(busIp, messageBean.getIp(), "验证数据库Ip");
			Logger.verifyEquals("\""+body+"\"", messageBean.getBody(), "验证数据库Body");
			Logger.verifyEquals(format.format(date).subSequence(0, 16), messageBean.getCtime().toString().subSequence(7, 23), "验证数据库Ctime");
			Logger.verifyEquals(busIp, messageBean.getBusIp(), "验证数据库BusIp");			
			Logger.verifyEquals(3, messageBean.getNstatus(), "验证数据库nstatus:3-检测进入补单");
			Logger.verifyEquals(1, messageBean.getPstatus(), "验证数据库pstatus:1-分发成功");
						
			// 验证补单库
			MQMessageCompensateBean compensate = new MQMessageCompensateWapper().getCompensateByUuid(appName, codeName, messageBean.getUuid());
				
			Logger.verifyEquals(messageBean.getAid(), compensate.getAppid(), "验证数据库MQ_Message_Compensate字段AppId");
			Logger.verifyEquals(messageBean.getCode(), compensate.getCode(), "验证数据库MQ_Message_Compensate字段Code");
			Logger.verifyEquals(messageBean.getMid(), compensate.getMid(), "验证数据库MQ_Message_Compensate字段mId");
			//Logger.verifyEquals(format.format(date2).subSequence(0, 16), compensate.getRtimeout().toString().subSequence(7, 23), "验证数据库MQ_Message_Compensate字段Rtimeout");
			Logger.verifyEquals(1, compensate.getRetrycount(), "验证数据库MQ_Message_Compensate字段RetryCount");
			Logger.verifyEquals(3, compensate.getSource(), "验证数据库MQ_Message_Compensate字段Source补单来源:3-补偿站");
			Logger.verifyEquals(2, compensate.getNstatus(), "验证数据库MQ_Message_Compensate字段nStatus:2-补发成功");
			Logger.verifyEquals("bamei_qusi_c1", compensate.getCid(), "验证数据库MQ_Message_Compensate字段Cid");
						
			// 验证Status表生成记录
			statusList = new MQMessageStatusWapper().getStatusByMid(appName, msguniqueid);
			int num2 = statusList.size();

			Logger.verifyEquals(1,num2-num1, "验证数据库MQ_Message_Status新生成一条记录");
						
			MQMessageStatusBean status = statusList.get(num2-1);
									 
			SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); 
						
			Logger.verifyEquals(messageBean.getUuid(), status.getUuid(), "验证数据库MQ_Message_Status字段uuid");
			Logger.verifyEquals(messageBean.getMid(), status.getMid(), "验证数据库MQ_Message_Status字段Mid");
			Logger.verifyEquals("bamei_qusi_c1", status.getCid(), "验证数据库MQ_Message_Status字段Cid");
			Logger.verifyEquals("PushOk", status.getStatus(), "验证数据库MQ_Message_Status字段Source");
			Logger.verifyEquals("Compensate", status.getSource(), "验证数据库MQ_Message_Status字段uuid");	
			Logger.verifyEquals(true, status.getResult().contains("ok, bamei_qusi_c1"), "验证数据库MQ_Message_Status字段Result");
			Logger.verifyEquals(true, status.getResult().contains("http://mockforpay.iapi.ymatou.com/api/messagebus/return/ok"), "验证数据库MQ_Message_Status字段Result");
			Logger.verifyEquals(true, status.getR_ip().contains("135"), "验证数据库MQ_Message_Status字段R_ip");
			
			// 开启自动补单
			new MqCompensateCallService().StartMqCompensate();
			
		} catch (Exception e) {
			Logger.fail(e);
			
			// 开启自动补单
			try {
				new MqCompensateCallService().StartMqCompensate();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_002() {
		Logger.start(true,"补发消息-接收失败");
		try {
			// 关掉自动补单
			new MqCompensateCallService().StopMqCompensate();
			
			PublishBean publishBean = new MqPublishCallService().setPublishBeanForRecieveFail();
			PublishCall publishCall = new MqPublishCallService().publishCall(publishBean);
			
			new MqCompensateCallService().CheckToChompensateCall(publishBean.getAppId(), publishBean.getCode());
			
			compensateBean.setAppId(publishBean.getAppId());
			compensateBean.setCode(publishBean.getCode());
			
			String appName = publishBean.getAppId();
			String msguniqueid = publishBean.getMsgUniqueId();
			String codeName = publishBean.getCode();
			
			List<MQMessageStatusBean> statusList =new MQMessageStatusWapper().getStatusByMid(appName, msguniqueid);
			int num1 = statusList.size();

			Date dNow = new Date(); // 当前时间
	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.MINUTE, -10); // 设置为前一天
	        Date dBefore = calendar1.getTime(); // 得到前一天的时间
	        
			new MQMessageCompensateWapper().update(appName, codeName, MapUtil.hashMap("mid", msguniqueid), MapUtil.hashMap("rtime", dBefore));
			//new MQMessageCompensateWapper().update(appName, codeName, MapUtil.hashMap("mid", msguniqueid), MapUtil.hashMap("rtimeout", dBefore));
			
			compensateCall.setData(compensateBean);
			compensateCall.callService();		
			
			//Thread.sleep(1000);
			
			Logger.verifyEquals(ECode.SUCCESS, compensateCall.getCode(), "验证Code");
			Logger.verifyEquals("NULL", compensateCall.getMsg().toUpperCase(), "验证Msg");

			MQMessageBean messageBean = new MQMessageWapper().getMessageByMid(appName,codeName,msguniqueid);

			int flag=0;
			
			while(messageBean==null || messageBean.getPstatus()!=2 && flag<20)
			{
				Thread.sleep(200);
				flag++;
				messageBean = new MQMessageWapper().getMessageByMid(appName,codeName,msguniqueid);
			}

			Date nowTime=new Date(); 
			Date date = new Date(nowTime.getTime()-8*60*60*1000);
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd'T'HH"); 
			
			// 验证消息成功
			Logger.verifyEquals(publishBean.getAppId(), messageBean.getAid(), "验证数据库Aid");
			Logger.verifyEquals(publishBean.getCode(), messageBean.getCode(), "验证数据库Code");
			Logger.verifyEquals(publishBean.getIp(), messageBean.getIp(), "验证数据库Ip");
			Logger.verifyEquals("\""+publishBean.getBody()+"\"", messageBean.getBody(), "验证数据库Body");
			//Logger.verifyEquals(sdf.format(date), messageBean.getCtime().toString().subSequence(7, 20), "验证数据库Ctime,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(true, messageBean.getBusIp().contains("133"), "验证数据库BusIp");			
			Logger.verifyEquals(2, messageBean.getNstatus(), "验证数据库nstatus:0-进入RabbitMQ,2-分发进入补单");
			//Logger.verifyEquals(sdf.format(date),messageBean.getPushtime().toString().subSequence(7, 20), "验证数据库Pushtime,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(2, messageBean.getPstatus(), "验证数据库pstatus:2-补单中");
			
			// 验证进入补单库
			MQMessageCompensateBean compensate = new MQMessageCompensateWapper().getCompensateByUuid(appName, codeName, messageBean.getUuid());
			Thread.sleep(2000);
			while(compensate==null || compensate.getNstatus()!=1 && flag<20)
			{
				Thread.sleep(200);
				flag++;
				compensate = new MQMessageCompensateWapper().getCompensateByUuid(appName, codeName, messageBean.getUuid());
			}
			
			Logger.verifyEquals(messageBean.getAid(), compensate.getAppid(), "验证数据库MQ_Message_Compensate字段AppId");
			Logger.verifyEquals(messageBean.getCode(), compensate.getCode(), "验证数据库MQ_Message_Compensate字段Code");
			Logger.verifyEquals(messageBean.getMid(), compensate.getMid(), "验证数据库MQ_Message_Compensate字段mId");
//			Logger.verifyEquals(sdf.format(date), compensate.getRtimeout().toString().subSequence(7, 20), "验证数据库MQ_Message_Compensate字段Rtimeout,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(true, compensate.getSource().equals(2)||compensate.getSource().equals(3), "验证数据库MQ_Message_Compensate字段Source补单来源:1-接收站,2-分发站,3-补偿站");
			Logger.verifyEquals(1, compensate.getNstatus(), "验证数据库MQ_Message_Compensate字段nStatus：1-补发中");
			Logger.verifyEquals("bamei_qusi_c1", compensate.getCid(), "验证数据库MQ_Message_Compensate字段Cid");

			// 验证Status表生成记录
			List<MQMessageStatusBean> statusList2 = new ArrayList<>();
			 statusList2 = new MQMessageStatusWapper().getStatusByMid(appName, msguniqueid);
			int num2 = statusList2.size();

			Logger.verifyEquals(true,(num2-num1)>=1, "验证数据库MQ_Message_Status新生成一条记录");
			
			MQMessageStatusBean status = statusList2.get(num2-1);
						 
			SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd'T'HH"); 
			
			Logger.verifyEquals(messageBean.getUuid(), status.getUuid(), "验证数据库MQ_Message_Status字段uuid");
			Logger.verifyEquals(messageBean.getMid(), status.getMid(), "验证数据库MQ_Message_Status字段Mid");
			Logger.verifyEquals("bamei_qusi_c1", status.getCid(), "验证数据库MQ_Message_Status字段Cid");
			Logger.verifyEquals("PushFail", status.getStatus(), "验证数据库MQ_Message_Status字段Status");
			Logger.verifyEquals("Compensate", status.getSource(), "验证数据库MQ_Message_Status字段Source");	
			//Logger.verifyEquals(sdf2.format(date), status.getCtime().toString().subSequence(7, 20), "验证数据库MQ_Message_Status字段Ctime,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(true, status.getResult().contains("fail, bamei_qusi_c1"), "验证数据库MQ_Message_Status字段Result");
			Logger.verifyEquals(true, status.getResult().contains("http://mockforpay.iapi.ymatou.com/api/messagebus/return/fail"), "验证数据库MQ_Message_Status字段Result");
			Logger.verifyEquals(true, status.getR_ip().contains("135"), "验证数据库MQ_Message_Status字段R_ip");
			
			// 开启自动补单
			new MqCompensateCallService().StartMqCompensate();
			
		} catch (Exception e) {
			Logger.fail(e);
			
			// 开启自动补单
						try {
							new MqCompensateCallService().StartMqCompensate();
						} catch (ClientProtocolException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						} catch (IOException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_003() {
		Logger.start(true,"补发消息-补发失败");
		try {
			// 关掉自动补单
			new MqCompensateCallService().StopMqCompensate();
			
			PublishBean publishBean = new MqPublishCallService().setPublishBeanForRecieveFail();
			publishBean.setCode("zaiqusi");
			PublishCall publishCall = new MqPublishCallService().publishCall(publishBean);
			
			new MqCompensateCallService().CheckToChompensateCall(publishBean.getAppId(), publishBean.getCode());
			
			compensateBean.setAppId(publishBean.getAppId());
			compensateBean.setCode(publishBean.getCode());
			
			String appName = publishBean.getAppId();
			String msguniqueid = publishBean.getMsgUniqueId();
			String codeName = publishBean.getCode();
			
			List<MQMessageStatusBean> statusList = new ArrayList<>(); 
			statusList=new MQMessageStatusWapper().getStatusByMid(appName, msguniqueid);
			int num1 = statusList.size();			
			
			Date dNow = new Date(); // 当前时间
	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.MINUTE, -10); // 设置为前一天
	        Date dBefore = calendar1.getTime(); // 得到前一天的时间
	        
			new MQMessageCompensateWapper().update(appName, codeName, MapUtil.hashMap("mid", msguniqueid), MapUtil.hashMap("rtime", dBefore));
			new MQMessageCompensateWapper().update(appName, codeName, MapUtil.hashMap("mid", msguniqueid), MapUtil.hashMap("rtimeout", dBefore));
			
			compensateCall.setData(compensateBean);
			compensateCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, compensateCall.getCode(), "验证Code");
			Logger.verifyEquals("NULL", compensateCall.getMsg().toUpperCase(), "验证Msg");
			
			MQMessageBean messageBean = new MQMessageWapper().getMessageByMid(appName,codeName,msguniqueid);

			int flag=0;
			
			while(messageBean==null || messageBean.getPstatus()!=3 && flag<40)
			{
				Thread.sleep(10000);
				flag++;
				messageBean = new MQMessageWapper().getMessageByMid(appName,codeName,msguniqueid);
			}

			Date nowTime=new Date(); 
			Date date = new Date(nowTime.getTime()-8*60*60*1000);
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd'T'HH"); 
			
			// 验证消息成功
			Logger.verifyEquals(publishBean.getAppId(), messageBean.getAid(), "验证Message数据库Aid");
			Logger.verifyEquals(publishBean.getCode(), messageBean.getCode(), "验证Message数据库Code");
			Logger.verifyEquals(publishBean.getIp(), messageBean.getIp(), "验证Message数据库Ip");
			Logger.verifyEquals("\""+publishBean.getBody()+"\"", messageBean.getBody(), "验证Message数据库Body");
			//Logger.verifyEquals(sdf.format(date), messageBean.getCtime().toString().subSequence(7, 20), "验证数据库Ctime,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(true, messageBean.getBusIp().contains("133"), "验证Message数据库BusIp");			
			Logger.verifyEquals(2, messageBean.getNstatus(), "验证Message数据库nstatus:0-进入RabbitMQ,2-分发进入补单");
			//Logger.verifyEquals(sdf.format(date),messageBean.getPushtime().toString().subSequence(7, 20), "验证数据库Pushtime,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(3, messageBean.getPstatus(), "验证Message数据库pstatus:2-补单中,3-补发失败");
			
			// 验证进入补单库
			MQMessageCompensateBean compensate = new MQMessageCompensateWapper().getCompensateByUuid(appName, codeName, messageBean.getUuid());
	
			while(compensate==null || compensate.getNstatus()!=1 && flag<100)
			{
				Thread.sleep(200);
				flag++;
				compensate = new MQMessageCompensateWapper().getCompensateByUuid(appName, codeName, messageBean.getUuid());
			}
			
			Logger.verifyEquals(messageBean.getAid(), compensate.getAppid(), "验证数据库MQ_Message_Compensate字段AppId");
			Logger.verifyEquals(messageBean.getCode(), compensate.getCode(), "验证数据库MQ_Message_Compensate字段Code");
			Logger.verifyEquals(messageBean.getMid(), compensate.getMid(), "验证数据库MQ_Message_Compensate字段mId");
//			Logger.verifyEquals(sdf.format(date), compensate.getRtimeout().toString().subSequence(7, 20), "验证数据库MQ_Message_Compensate字段Rtimeout,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(2, compensate.getSource(), "验证数据库MQ_Message_Compensate字段Source补单来源:1-接收站,2-分发站");
			Logger.verifyEquals(3, compensate.getNstatus(), "验证数据库MQ_Message_Compensate字段nStatus：1-补发中,3-补发失败");
			Logger.verifyEquals("bamei_zaiqusi_c1", compensate.getCid(), "验证数据库MQ_Message_Compensate字段Cid");
			
			Thread.sleep(2000);
			
			// 验证Status表生成记录
			List<MQMessageStatusBean> statusList2 = new ArrayList<>();
			 statusList2 = new MQMessageStatusWapper().getStatusByMid(appName, msguniqueid);
			int num2 = statusList2.size();

			Logger.verifyEquals(true,(num2-num1)>=1, "验证数据库MQ_Message_Status新生成一条记录");
			
			MQMessageStatusBean status = statusList2.get(num2-1);
						 
			SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd'T'HH"); 
			
			Logger.verifyEquals(messageBean.getUuid(), status.getUuid(), "验证数据库MQ_Message_Status字段uuid");
			Logger.verifyEquals(messageBean.getMid(), status.getMid(), "验证数据库MQ_Message_Status字段Mid");
			Logger.verifyEquals("bamei_zaiqusi_c1", status.getCid(), "验证数据库MQ_Message_Status字段Cid");
			Logger.verifyEquals("PushFail", status.getStatus(), "验证数据库MQ_Message_Status字段Status");
			Logger.verifyEquals("Compensate", status.getSource(), "验证数据库MQ_Message_Status字段Source");	
			//Logger.verifyEquals(sdf2.format(date), status.getCtime().toString().subSequence(7, 20), "验证数据库MQ_Message_Status字段Ctime,如果相差1小时，可能是由于换小时引起");
			Logger.verifyEquals(true, status.getResult().contains("fail, bamei_zaiqusi_c1"), "验证数据库MQ_Message_Status字段Result");
			Logger.verifyEquals(true, status.getResult().contains("http://mockforpay.iapi.ymatou.com/api/messagebus/return/fail"), "验证数据库MQ_Message_Status字段Result");
			Logger.verifyEquals(true, status.getR_ip().contains("135"), "验证数据库MQ_Message_Status字段R_ip");
			
			// 开启自动补单
			new MqCompensateCallService().StartMqCompensate();
			
		} catch (Exception e) {
			Logger.fail(e);
			
			// 开启自动补单
						try {
							new MqCompensateCallService().StartMqCompensate();
						} catch (ClientProtocolException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						} catch (IOException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_004() {
		Logger.start(true,"补发消息-AppId空");
		try {
			
			String appName = "testbamei";
			String codeName = "buqusi";
			
			//compensateBean.setAppId(appName);
			compensateBean.setCode(codeName);

			compensateCall.setData(compensateBean);
			compensateCall.callService();		
			
			Logger.verifyEquals("400", compensateCall.getCode(), "验证Code");
			Logger.verifyEquals("参数异常|invalid appId:null", compensateCall.getMsg(), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_005() {
		Logger.start(true,"补发消息-Code空");
		try {
			
			String appName = "testbamei";
			String codeName = "buqusi";
			
			compensateBean.setAppId(appName);
			//compensateBean.setCode(codeName);

			compensateCall.setData(compensateBean);
			compensateCall.callService();		
			
			Logger.verifyEquals("400", compensateCall.getCode(), "验证Code");
			Logger.verifyEquals("参数异常|invalid code:null", compensateCall.getMsg(), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_006() {
		Logger.start(true,"补发消息-AppId不存在");
		try {
			
			String appName = "testbage";
			String codeName = "buqusi";
			
			compensateBean.setAppId(appName);
			compensateBean.setCode(codeName);

			compensateCall.setData(compensateBean);
			compensateCall.callService();		
			
			Logger.verifyEquals("400", compensateCall.getCode(), "验证Code");
			Logger.verifyEquals("参数异常|invalid appId:testbage", compensateCall.getMsg(), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Compensate_007() {
		Logger.start(true,"补发消息-Code不存在");
		try {
			
			String appName = "testbamei";
			String codeName = "buqusi";
			
			compensateBean.setAppId(appName);
			compensateBean.setCode(codeName);

			compensateCall.setData(compensateBean);
			compensateCall.callService();		
			
			Logger.verifyEquals("400", compensateCall.getCode(), "验证Code");
			Logger.verifyEquals("参数异常|invalid code:buqusi", compensateCall.getMsg(), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}